﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _01_TripleRotation
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputK = Console.ReadLine();
            string drunkNumber = inputK;
            if (int.Parse(inputK) != 0)
            {
                for (int i = 1; i <= 3; i++)
                {
                    drunkNumber = RotateNumber(drunkNumber);
                }
            }
            else 
            {
                drunkNumber = "0";
            }
            Console.WriteLine(drunkNumber);
        }

        private static string RotateNumber(string drunkNumber)
        {
            string current;
            char lastSymbol = drunkNumber[drunkNumber.Length - 1];
            drunkNumber = drunkNumber.Remove(drunkNumber.Length - 1);
            if (lastSymbol != '0')
            {
                current = drunkNumber.Insert(0, lastSymbol.ToString());
            }
            else
            {
                current = drunkNumber;
            }
            return current;
        }
    }
}
